﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class ZHCX_XLTJB : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    if (!Page.IsPostBack)
    {
      if (!ProjectPrivate.GetQX("36"))
      {
        Server.Transfer("~\\blank.aspx");
      }
      DataSet ds = CBSJ.GetYear();
      CommonUse.BindDDL(ds, "year", "year", DateTime.Now.Year.ToString(), ddlYear);
      //ddlMonth.SelectedValue = DateTime.Now.ToString("yyyy-MM").Substring(5, 2);
    }
    BindGrid();
  }

  protected void BindGrid()
  {
    string sql = @"select ROW_NUMBER() OVER (ORDER BY KHXX_SFSB) AS xh,KHXX_SFSB,
  SUM(YSQL_1) YSQL_1,SUM(YSQF_1) YSQF_1,
  SUM(YSQL_2) YSQL_2,SUM(YSQF_2) YSQF_2,
  SUM(YSQL_3) YSQL_3,SUM(YSQF_3) YSQF_3,
  SUM(YSQL_4) YSQL_4,SUM(YSQF_4) YSQF_4,
  SUM(YSQL_5) YSQL_5,SUM(YSQF_5) YSQF_5,
  SUM(YSQL_6) YSQL_6,SUM(YSQF_6) YSQF_6,
  SUM(YSQL_7) YSQL_7,SUM(YSQF_7) YSQF_7,
  SUM(YSQL_8) YSQL_8,SUM(YSQF_8) YSQF_8,
  SUM(YSQL_9) YSQL_9,SUM(YSQF_9) YSQF_9,
  SUM(YSQL_10) YSQL_10,SUM(YSQF_10) YSQF_10,
  SUM(YSQL_11) YSQL_11,SUM(YSQF_11) YSQF_11,
  SUM(YSQL_12) YSQL_12,SUM(YSQF_12) YSQF_12
from f_ZHCX_yd({0}) a
where KHXX_SFSB<>''
group by khxx_sfsb ";
    sql = string.Format(sql, ddlYear.SelectedValue.ToString());
    DataSet ds = DbHelperSQL.Query(sql);
    DataColumn dc1 = new DataColumn("HJQL", typeof(System.String));
    dc1.Expression = "YSQL_1+YSQL_2+YSQL_3+YSQL_4+YSQL_5+YSQL_6+YSQL_7+YSQL_8+YSQL_9+YSQL_10+YSQL_11+YSQL_12";
    ds.Tables[0].Columns.Add(dc1);
    DataColumn dc2 = new DataColumn("HJQF", typeof(System.String));
    dc2.Expression = "YSQF_1+YSQF_2+YSQF_3+YSQF_4+YSQF_5+YSQF_6+YSQF_7+YSQF_8+YSQF_9+YSQF_10+YSQF_11+YSQF_12";
    ds.Tables[0].Columns.Add(dc2);
    ASPxGridView1.DataSource = ds;
    ASPxGridView1.DataBind();
  }

  protected void btnQuery_Click(object sender, EventArgs e)
  {

  }

  protected void btnExport_Click(object sender, EventArgs e)
  {
    this.ASPxGridViewExporter1.WriteXlsToResponse();
  }
}